<html>
<head>
<title>Sale</title>
<style type="text/css">
body {
	font-family:verdana,arial,sans-serif;
	font-size:10pt;
	margin:30px;
	background-color:#ffcc00;
	}
</style>
</head>
<body>
<h1>Make A Sale:</h1><br />

<form name= "addorder" action="makeasale_action.php" method="post">


<?php
$username="bsc353_4";
$password="sonbeans";
$database="bsc353_4";

mysql_connect("clipper.encs.concordia.ca",$username,$password) or die ("Unable to connect to database");

@mysql_select_db($database) or die ("Unable to select database");

$idquery= "Select ID from Customer";
$isbnquery= "Select ISBN from Book";
$branchquery= "Select branchID from StoreBranch";
$employeequery= "Select employeeID from Employee";

$allid= mysql_query($idquery) or die ("Query did not work");
$allisbn= mysql_query($isbnquery) or die ("Query did not work");
$allbranch=mysql_query($branchquery) or die ("Query did not work");
$allemp=mysql_query($employeequery) or die ("Query did not work");

$numid= mysql_numrows($allid);
$numisbn= mysql_numrows($allisbn);
$numbranch= mysql_numrows($allbranch);
$numemp= mysql_numrows($allemp);

//$employee = mysql_query("") or die ("Query did not work");


echo"Select Customer: ";
echo"<select name='customerid'>";
echo"<option>Select One</option>";
$i=0;
while($i<$numid)
    {
    $value=mysql_result($allid,$i,"ID");
    $customer = mysql_query("SELECT name FROM Customer WHERE ID=$value") or die ("Query did not work");
    $cust = mysql_result($customer,0,"name");
    echo "<option value=$value>$cust - $value</option>";
    ++$i;
    }   
echo"</select><br /><br />";

echo"Select Book ISBN: ";
echo"<select name='ISBN'>";
echo"<option>Select One</option>";
$i=0;
while($i<$numisbn)
    {
    $value=mysql_result($allisbn,$i,"ISBN");
    echo "<option>$value</option>";
    ++$i;
    }
echo"</select><br /><br />";

echo"Select Store Branch: ";
echo"<select name='branchid'>";
echo"<option>Select One</option>";
$i=0;
while($i<$numbranch)
    {
    $value=mysql_result($allbranch,$i,"branchID");
    $branch = mysql_query("SELECT name FROM StoreBranch WHERE branchID=$value") or die ("Query did not work");
    $branchname = mysql_result($branch,0,"name");
    echo "<option value=$value>$branchname - $value</option>";
    ++$i;
    }   
echo"</select><br /><br />";

echo"Select Employee: ";
echo"<select name='employeeid'>";
echo"<option>Select One</option>";
$i=0;
while($i<$numemp)
    {
    $value=mysql_result($allemp,$i,"employeeID");
    $employee = mysql_query("SELECT name FROM Employee WHERE employeeID=$value") or die ("Query did not work");
    $emp = mysql_result($employee,0,"name");
    echo "<option value=$value>$emp - $value</option>";
    ++$i;
    }   
echo"</select><br /><br />";

mysql_close();

?>

<input type="submit" value="Confirm">

</form> 


</body>
</html>